package com.example.meetdroid;

import com.example.meetdroid.main.Globals;


import com.example.meetdroid.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class AddUserActivity extends Activity {
	
	private EditText cUserName;
	
	private Button cBtnAddContact;
	private Button cBtnCancel;
	@Override
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_adduser);
        this.cUserName = (EditText) findViewById(R.id.txtUserNameAddUser);
        cBtnCancel =  (Button) findViewById(R.id.BtnCancelAddUser);
        cBtnCancel.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finishHim(1);			
			}
		});
 
        cBtnAddContact = (Button) findViewById(R.id.BtnAddContactAddUser);
        
        cBtnAddContact.setOnClickListener(new OnClickListener() {
			
		@Override
		public void onClick(View v) {
			String _UserName= "";
			
			_UserName= cUserName.getText().toString();
			AddContact(_UserName);
			
			}
        });
	}
   
	private void AddContact(String pUserName){
		
		Globals.Client.SendFriendRequest(pUserName);
		finishHim(1);
	}
	private void finishHim(int pResult){
		
		Intent returnIntent = new Intent();
		returnIntent.putExtra("result",pResult);
		setResult(RESULT_OK,returnIntent);     
		finish();
	}
}
